//
// Include file for stepper motor class
//
// ZJ Laczik
//
// 19/11/1998
//
// Revision history:
//

#ifndef STEPPER_H
#define STEPPER_H

#include <qwidget.h>
#include <qobject.h>

#ifndef BOOL
#define BOOL int
#endif
#ifndef TRUE
#define TRUE (BOOL)1
#endif
#ifndef FALSE
#define FALSE (BOOL)0
#endif

#define LPT_BASE 0x378

//#define STEP_MARK 500
//#define STEP_SPACE_MIN (1000-STEP_MARK)
//#define STEP_SPACE_MAX (5000-STEP_MARK)
//#define STEP_DEC 10

#define STEP_MARK 1000
#define STEP_SPACE_MIN (2000-STEP_MARK)
#define STEP_SPACE_MAX (10000-STEP_MARK)
#define STEP_DEC 100

#define X_AX 1
#define Y_AX 2
#define Z_AX 3

// class declaration
//==================
class Stepper : public QObject  {
	Q_OBJECT
public:
	Stepper(QWidget *parent=0);
	~Stepper();
  
	void SetStopFlagPointer(bool * pSF);
	void StepRel(long int steps, int axes);
	void StepAbs(long int steps, int axes);
	long int GetPos(int axes);
public slots:
	void SetPos(long int newpos, int axes);
signals:
	void Position(float x, float y, float z);
private:
	int ppdev ;
	long int delay_cal;
	long int delay_res;
	long int current_pos[4];
	long int space;
private:
	bool StopFlag;
	bool * pStopFlag;
	void usec_delay(long int usecs);
	void init_usec_delay();
	void one_step(BOOL forward, int axes);
};
#endif
